<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../js/jquery.min.js"></script>
    <script>
        $(function(){

            $("#getCheckCode").click(function(){
                var second = 60;
                var time = window.setInterval(function(){
                    if(second>0){
                        $("#getCheckCode").prop("disabled",true);
                        $("#getCheckCode").val((second--)+"s后重新获取");
                    }else{
                        second = 60;
                        $("#getCheckCode").val("重新获取");
                        $("#getCheckCode").prop("disabled",false);
                        window.clearInterval(time);
                    }

                },1000);
                $.get("../User/phone?phone="+$("#telephone").val(),function(data){
                })

            });
            $("#btn").click(function(){
                var birthday = $("#birthday").val();
                birthday = birthday.replace(/-/g,"/");
                $("#birthdayHidden").val(birthday);//SpringMVC默认的日期格式为  yyyy/MM/dd , date默认值是yyyy-MM-dd
               $.post('../User/register?checkCode='+$("#checkCode").val(),$("#frm").serialize(),function(data){
                  if(data.flag){
                      alert(data.message);
                      window.location.reload();
                  }else{
                      alert(data.message);
                  }
               });
            });


        })
        function getDate(obj){
            alert(obj.value);
        }
    </script>
</head>
<body>

    <h1>用户注册</h1>
    <form id="frm">
        <table>
            <tr>
                <td>用户名</td>
                <td><input type="text" name="username"/> </td>
            </tr>
            <tr>
                <td>密码</td>
                <td><input type="password" name="password"/> </td>
            </tr>
            <tr>
                <td>确认密码</td>
                <td><input type="password" name="repassword"/> </td>
            </tr>
            <tr>
                <td>手机号</td>
                <td><input type="text" id="telephone" name="telephone"/> </td>
            </tr>
            <tr>
                <td>验证码</td>
                <td>
                    <input type="text" id="checkCode" size="6"/>
                    <input type="button" value="获取验证码" id="getCheckCode"/>
                </td>
            </tr>
            <tr>
                <td>性别</td>
                <td>
                    <input type="radio" name="gender" value="1" checked/>男
                    <input type="radio" name="gender" value="0"/>女
                </td>
            </tr>
            <tr>
                <td>生日</td>
                <td>
                    <input  type="date"   id="birthday" />
                    <input type="hidden" id="birthdayHidden" name="birthday"/>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <input type="button" id="btn" value="注册"/>
                </td>
            </tr>

        </table>
    </form>
</body>
</html>